print("Введите строку")
G=input()
G=""
So1=So2=So3=So4=Sz1=Sz2=Sz3=Sz4=0
for sin in G:
    if sim == "(":
        G=G+sim
        So1+=1
    if sim == "[":
        G=G+sim
        So2+=1
    if sim == "{":
        G=G+sim
        So3+=1
    if sim == "<":
        G=G+sim
        So4+=1
    if sim == ")":
        Sz1+=1
        if len(G) !=0 and G[len(G)-1]=="(":
            G=G[:-1]
    if sim == "]":
        Sz2+=1
        if len(G) !=0 and G[len(G)-1]== "[":
            G=G[:-1]
    if sim == "}":
        Sz3+=1
        if len(G) !=0 and G[len(G)-1]=="{":
            G=G[:-1]
    if sim == ">":
        Sz4+=1
        if len(G) !=0 and G[len(G)-1]=="<":
            G=G[:-1]
if len(G)==0 and So1==Sz1 and So2==Sz2 and So3==Sz3 and So4==Sz4:
    print("True")
else:
    print("False")
